package com.pointi.emoTools;

import java.io.Serializable;

@SuppressWarnings("serial")

public class EmotionPacket implements Serializable
{
	// ____________________________________________________________________________________________________
	
	static public final int _FIRST_PACKET = 1 ;
	static public final int _MIDDLE_PACKET = 2 ;
	static public final int _LAST_PACKET = 3 ;
	
	// ____________________________________________________________________________________________________
	// XXX
	//		[Emotion Packet for Emoray 2.0] 2014.02.20
	// 		-	Frame Length : 160sample = 20ms (for 8kHz Sampling Rate)

	static public final int frameSize = 160 ; 
	static public final int headerSize = 640 ;
	static public final int packetSize = headerSize + frameSize  ;

	// ____________________________________________________________________________________________________
	// XXX
	//		-	pTYPE	: Packet Type (1) Start (2) On (3) End
	//		-	TID		: Thread ID
	//		-	SIDE	: Call Side (for Stereo) (1) Agent (2) Customer
	
	private int pTYPE ;
	private int TID ;
	private int CALLKEY ;
	private int SIDE ;
	private double ANGER ;
	private int ANGERCNT ;
	private double NEUTRAL ;
	private int NEUTRALCNT ;
	private double ENERGY ;
	private short [] SAMPLE ;
	private double [] RESULT ;
	
	// ____________________________________________________________________________________________________ 

	public EmotionPacket(int pTYPE, int TID, String CALLKEY, int SIDE, short [] SAMPLE)
	{
		this.pTYPE = pTYPE ;
		this.TID = TID ;
		this.CALLKEY = Integer.valueOf(CALLKEY) ;
		this.SIDE = SIDE ;
		this.ANGER = 0 ;
		this.ANGERCNT = 0 ;
		this.NEUTRAL = 0 ;
		this.NEUTRALCNT = 0 ;
		this.ENERGY = 0 ;
		this.SAMPLE = SAMPLE ;
	}

	// ____________________________________________________________________________________________________
	// Setter
	
	public void setPacketType (int pTYPE) { this.pTYPE = pTYPE ; }
	public void setSample (short [] SAMPLE) { this.SAMPLE = SAMPLE ; }
	public void setResult (double [] RESULT) { this.RESULT = RESULT ; }
	public void setAnger (double ANGER) { this.ANGER = ANGER ; }
	public void setNeutral (double NEUTRAL) { this.NEUTRAL = NEUTRAL ; }
	public void setCount (int ANGERCNT, int NEUTRALCNT)
	{
		this.ANGERCNT = ANGERCNT ;
		this.NEUTRALCNT = NEUTRALCNT ;
	}
	public void setEnergy (double ENERGY) { this.ENERGY = ENERGY ; }

	// ____________________________________________________________________________________________________
	// Getter

	public int getCallkey() { return this.CALLKEY ; }
	public int getPacketType () { return pTYPE ; }
	public int getThreadID () { return TID ; }
	public int getCallSide () { return SIDE ; }
	public short [] getSample () { return SAMPLE ; }
	public double [] getResult () { return RESULT ; }
	public int getAngerCount () { return ANGERCNT ; }
	public int getNeutralCount () { return NEUTRALCNT ; }
	public String getQuery(String subTIME)
	{
		String mQuery = "" + CALLKEY +
						"," + subTIME +
						"," + pTYPE +
						"," + SIDE +
						"," + ANGER +
						"," + NEUTRAL +
						"," + ENERGY +
						"," + ANGERCNT +
						"," + NEUTRALCNT +
						"," + RESULT[3] +
						"," + RESULT[2] +
						"," + RESULT[5] +
						"," + RESULT[4] +
						" " ;
		return mQuery ;
	}
}